<%@ Page Language="C#" MasterPageFile="~/MasterDefault.master" AutoEventWireup="True"
    Inherits="TeamTime.TimeEntriesForm" Title="Team Time - TimeEntries" StylesheetTheme="Default"
    CodeBehind="TimeEntriesForm.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="TimeEntryFormControl.ascx" TagName="TimeEntryFormControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true">
        <Services>
            <asp:ServiceReference Path="AutoComplete.asmx" />
        </Services>
    </asp:ScriptManager>
    <clib:UpdatePanelExtender runat="server" ID="UpdatePanelExtender1" UpdateMode="Conditional">
        <ContentTemplate>
            <h3>
                Time Entries &nbsp; &nbsp;<asp:Button runat="server" ID="btnAddNew" Text="Add New"
                    OnClick="btnAddNew_Click" CausesValidation="False" />
                &nbsp;&nbsp;&nbsp;<asp:HyperLink ID="HyperLink1" ForeColor="Orange" Target="_blank" NavigateUrl="~/Rpt_TimeSheet.aspx"
                    runat="server"><strong>Time Sheet Report</strong></asp:HyperLink>
            </h3>
            <asp:Button runat="server" ID="btnAddDummy" Text="Add New" Visible="true" Style="display: none;" />
            <clib:ModalPopupPanel runat="server" ID="popUp1" TargetControlID="btnAddDummy" Width="600px"
                Title="Time Entry" >
                <uc1:TimeEntryFormControl ID="TimeEntryFormControl1" runat="server" OnSaveClicked="TimeEntryFormControl1_SaveClicked" />
            </clib:ModalPopupPanel>
            <asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch" Height="71px">
                <table>
                    <tr>
                        <td>
                            <table id="tblHead" cellspacing="0" cellpadding="1" border="0" runat="server">
                                <tr>
                                    <td>
                                        Search for&nbsp;
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtSearchFor" runat="server" MaxLength="100" Width="150px"></asp:TextBox>
                                    </td>
                                    <td>
                                        Status
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlStatusFilter" runat="server" Enabled="false">
                                            <asp:ListItem Text="All"></asp:ListItem>
                                            <asp:ListItem Text="Invoiced"></asp:ListItem>
                                            <asp:ListItem Text="Uninvoiced"></asp:ListItem>
                                        </asp:DropDownList>
                                        &nbsp;&nbsp;&nbsp; Search in details&nbsp;
                                        <asp:CheckBox ID="chkSearchDetails" runat="server" Visible="true" />
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Person
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlStaffMemberID" runat="server" Enabled="false">
                                        </asp:DropDownList>
                                    </td>
                                    <td>
                                        Project
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlProjectIdFilter" runat="server" Enabled="false">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr id="trDates" runat="Server" visible="true">
                                    <td style="width: 105px">
                                        From Date
                                    </td>
                                    <td>
                                        <clib:TextBoxCalendar ID="txtFromDate" runat="server" EnableViewState="true" ClearText=" ">
                                        </clib:TextBoxCalendar>
                                    </td>
                                    <td>
                                        To Date
                                    </td>
                                    <td>
                                        <clib:TextBoxCalendar ID="txtToDate" runat="server" EnableViewState="true" ClearText=" ">
                                        </clib:TextBoxCalendar>
                                    </td>
                                    <td>
                                        <asp:Button ID="btnSearch" runat="server" CausesValidation="False" OnClick="btnSearch_Click"
                                            Text="Search &gt;&gt;" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td style="border-left: solid #858B97">
                            <img alt="spacer" src="App_Themes/Default/Images/spacer.gif" />
                        </td>
                        <td>
                            Invoice No.
                            <asp:TextBox ID="txtInvoice" runat="server" Text="" ValidationGroup="invoice"></asp:TextBox>
                        <br />
                            <asp:Button ID="btnInvoice" runat="Server" Text="Apply to selected" OnClick="btnInvoice_Click"
                                ValidationGroup="invoice" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <br />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SkinID="GridView"
                AllowPaging="True" PageSize="20" AllowSorting="True" DataKeyNames="ID" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting">
                <Columns>
                    <asp:TemplateField HeaderText="" SortExpression="ID">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkID" runat="server" CausesValidation="false" CommandName="Select"
                                Text="Edit" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="StartDate" HeaderText="Start" SortExpression="StartDate"
                        DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false"></asp:BoundField>
                    <asp:BoundField DataField="StartTime" HeaderText="Time" SortExpression="StartTime">
                    </asp:BoundField>
                    <asp:BoundField DataField="EndDate" Visible="False " HeaderText="End" SortExpression="EndDate"
                        DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false"></asp:BoundField>
                    <asp:BoundField DataField="EndTime" HeaderText="Time" SortExpression="EndTime"></asp:BoundField>
                    <asp:TemplateField HeaderText="" SortExpression="ID">
                        <HeaderTemplate>
                            Total Hours<br />
                            <asp:Label ID="lblTotalHours" runat="server" Width="65px" ReadOnly="true" Style="direction: rtl;
                                font-weight: bold;"></asp:Label>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblHours" runat="server" Text='<%# formatNum(DataBinder.Eval(Container, "DataItem.Duration") )%>'
                                MaxLength="9" Width="65px" ReadOnly="true" Style="direction: rtl;"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CompanyProject" HeaderText="Project" SortExpression="CompanyProject">
                    </asp:BoundField>
                    <asp:BoundField DataField="TaskName" HeaderText="Task" SortExpression="TaskName">
                    </asp:BoundField>
                    <asp:BoundField DataField="EstimatedHours" HeaderText="Est.Hours" SortExpression="EstimatedHours">
                    </asp:BoundField>
                    <asp:BoundField DataField="TimeEntryDescriptionShort" HeaderText="Description" SortExpression="TimeEntryDescriptionShort">
                    </asp:BoundField>
                    <asp:BoundField DataField="FullNameAndID" HeaderText="Person" SortExpression="FullNameAndID">
                    </asp:BoundField>
                    <asp:BoundField DataField="CreationDate" HeaderText="Created" SortExpression="CreationDate"
                        DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false"></asp:BoundField>
                    <asp:BoundField DataField="CompletionDate" HeaderText="Completed" SortExpression="CompletionDate"
                        DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false"></asp:BoundField>
                    <asp:BoundField DataField="InvoiceNumber" HeaderText="Inv. No."></asp:BoundField>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="chkCheckAll" runat="server" Checked="true" OnCheckedChanged="chkCheckAll_CheckedChanged"
                                AutoPostBack="true"></asp:CheckBox></HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkID" runat="server" Checked="true" Visible='<%# DataBinder.Eval(Container, "DataItem.InvoiceNumber") == DBNull.Value %>'>
                            </asp:CheckBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    No records found</EmptyDataTemplate>
                <PagerTemplate>
                    <table width="100%">
                        <tr>
                            <td style="text-align: left; font-size: 11px; width: 100px;">
                                Page
                                <asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                of
                                <asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount  %>' />
                            </td>
                            <td style="text-align: center; font-size: 11px;">
                                <asp:Panel ID="pnlPager" runat="server" DefaultButton="lnkGo">
                                    <asp:LinkButton ID="lnkFirst" runat="server" CausesValidation="False" CommandArgument="First"
                                        CommandName="Page" Text="Page 1" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                                        CommandName="Page" Text="<< Prev" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkNext" runat="server" CausesValidation="False" CommandArgument="Next"
                                        CommandName="Page" Text="Next >>" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkLast" runat="server" CausesValidation="False" CommandArgument="Last"
                                        CommandName="Page" Text='<%# "Page "+ ((GridView)Container.Parent.Parent).PageCount  %>' />&nbsp;&nbsp;&nbsp;
                                    <asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                    <asp:LinkButton ID="lnkGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                        CommandName="Page" Text="Go" /><!-- here set the CommandArgument of the Go Button to '-1' as the flag -->
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </PagerTemplate>
            </asp:GridView>
        </ContentTemplate>
    </clib:UpdatePanelExtender>
</asp:Content>
